﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Windows.Forms;

namespace Test2.Model
{
    public sealed class Database
    {

        private static readonly Database instance;
        public iDatabaseRepository databaseRepository;
        private string databaseType;

        static Database()
        {
            instance = new Database();
        }
        
        private Database()
        {
            databaseType = ConfigurationSettings.AppSettings["databaseType"].ToString();
            switch(databaseType.ToUpper())
            {
                case "LINQ": databaseRepository = new DatabaseLinqRepository(); break;
                case "ACCESS": databaseRepository = new DatabaseAccessRepository(); break;
                default: databaseRepository = new DatabaseDSRepository(); break;
            }
            //MessageBox.Show("Database Type: " + databaseRepository.GetType().ToString());
        }
        
        public static Database Instance
        {
            get
            {
                return instance;
            }
        }

        public iDatabaseRepository GetDatabase
        {
            get
            {
                return databaseRepository;
            }
        }

    }
}
